package com.skillscompetition.skillscompetition.bean;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author lwg
 * @since 2019-11-09
 */
@Data
@TableName("groupResults")
public class GroupResults implements Serializable, Comparable<GroupResults> {

    private static final long serialVersionUID = 1L;
    private String province;

    private Integer ranking;
    private Float groupTotal;

    @TableField(exist = false)
    private Float practicalOperationSum;
    @TableField(exist = false)
    private Float subtotal1;
    @TableField(exist = false)
    private Float subtotal2;
    @TableField(exist = false)
    private Float subtotal3;

    @TableField(exist = false)
    private Boolean flag = false;

    @Override
    public int compareTo(GroupResults groupResults) {
        if (this.groupTotal > groupResults.groupTotal) {
            return -1;
        } else if (this.groupTotal < groupResults.groupTotal) {
            return 1;
        } else {
            if (this.practicalOperationSum > groupResults.practicalOperationSum) {
                return -1;
            } else if (this.practicalOperationSum < groupResults.practicalOperationSum) {
                return 1;
            } else {
                if (this.subtotal1 > groupResults.subtotal1) {
                    return -1;
                } else if (this.subtotal1 < groupResults.subtotal1) {
                    return 1;
                } else {
                    if (this.subtotal2 > groupResults.subtotal2) {
                        return -1;
                    } else if (this.subtotal2 < groupResults.subtotal2) {
                        return 1;
                    } else {
                        if (this.subtotal3 > groupResults.subtotal3) {
                            return -1;
                        } else if (this.subtotal3 < groupResults.subtotal3) {
                            return 1;
                        } else {
                            this.flag = true;
                            groupResults.flag = true;
                            return 0;
                        }
                    }
                }
            }
        }
    }
}
